import 'package:dependencies_examples/amap/amap.dart';
import 'package:dependencies_examples/event_bus/subject.dart';
import 'package:dependencies_examples/event_bus/listener.dart';
import 'package:dependencies_examples/fl_chart/charts.dart';
import 'package:dependencies_examples/google_map/google_map.dart';
import 'package:dependencies_examples/intl/intl.dart';
import 'package:dependencies_examples/l10n/app_localizations.dart';
import 'package:dependencies_examples/logger.dart';
import 'package:dependencies_examples/permission/permission_page.dart';
import 'package:flutter/material.dart';

class HomePage extends StatelessWidget {
  const HomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text(AppLocalizations.of(context)!.helloWorld)),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            RouterButton(title: 'a map', target: AmapExps()),
            RouterButton(title: 'google map', target: MapSample()),
            RouterButton(title: 'logger', target: LoggerExps()),
            RouterButton(title: 'permission', target: PermissionPage()),
            RouterButton(title: 'chart', target: ChartExps()),
            RouterButton(title: 'intl', target: IntlExps()),
            RouterButton(title: 'event bus', target: EventSubject()),
          ],
        ),
      ),
    );
  }
}

class RouterButton extends StatelessWidget {
  final String title;
  final Widget target;

  const RouterButton({super.key, required this.title, required this.target});

  @override
  Widget build(BuildContext context) {
    return ElevatedButton(
      onPressed: () {
        Navigator.push(
          context,
          MaterialPageRoute(builder: (context) => target),
        );
      },
      child: Text(title),
    );
  }
}
